/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.actions.software;

import com.mapping.Software;
import com.opensymphony.xwork2.ActionSupport;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
/**
 *
 * @author PARDmx
 */
@Namespace(value = "/")
@Action(value = "consultaSoftwareP", results = {
@Result(name = "success", location = "/GestionSoftware/resultadoConsultaSoftware.jsp")})
public class ConsultasSoftwareAction extends ActionSupport{
    private Software software;
    private String idSoft;

    @Override
    public String execute() throws Exception {
        System.out.println("IDS "+ idSoft);
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventarios");
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();                     
        software = (Software)em.getReference(Software.class, idSoft);                         
        em.flush();
        tx.commit();
        em.close();           
        return SUCCESS;        
    }

    public Software getSoftware() {
        return software;
    }

    public void setIdSoft(String idSoft) {
        this.idSoft = idSoft;
    }
    
}
